class Person implements Comparable<Person>{

    @Override
    public int compareTo(Person o) {
        return 0;
    }
}
//泛型方法
class Algs{
    //泛型方法
    public<T extends Comparable<T>> T findMaxValue(T[] array){
        T max = array[0];
        for(int i =1;i<array.length;i++){
            if(max.compareTo(array[i])<0){
                max = array[i];
            }
        }
        return max;
    }
}
//静态方法
class Algs3{
    //泛型方法
    public static <T extends Comparable<T>> T findMaxValue(T[] array){
        T max = array[0];
        for(int i =1;i<array.length;i++){
            if(max.compareTo(array[i])<0){
                max = array[i];
            }
        }
        return max;
    }
}
class Alg<T extends Comparable<T>>{
    //T一定是实现了Comparable接口
    public T findMaxValue(T[] array){
        T max = array[0];
        for(int i =1;i<array.length;i++){
            if(max.compareTo(array[i])<0){
                max = array[i];
            }
        }
        return max;
    }
}
public class Dome {
    public static void main(String[] args) {
        Integer[] integer2 = {45,65,76};
        Integer ret11= Algs3.findMaxValue(integer2);
        System.out.println(ret11);
        System.out.println("=========");
        Algs algs = new Algs();
        Integer[] integer1 = {45,65,76};
        //类型推导
        Integer ret1 = algs.<Integer>findMaxValue(integer1);
        Integer ret2 = algs.findMaxValue(integer1);
        System.out.println(ret1);
        System.out.println("=========");
        Alg<Integer> alg = new Alg<>();
        Integer[] integers = {1,2,3,4};
        Integer ret = alg.findMaxValue(integers);
        System.out.println(ret);
        Alg<Person> alg2 = new Alg<>();
    }
    public static void main1(String[] args) {
        MyArray<Integer> myArray = new MyArray<>();
        myArray.setValue(0,10);
        myArray.setValue(1,100);
        int a = myArray.getValue(0);
        System.out.println(a);
        MyArray<String> myArray1 = new MyArray<>();
        myArray1.setValue(2,"ivsv");
        String a1 = myArray1.getValue(2);
        System.out.println(a1);
    }
}

